#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import allure
import logging
from typing import Literal


class Mouse:
    def __init__(self,draPage):
        from dragon.page import DraPage
        self.draPage:DraPage=draPage
        self._mouse=self.draPage._page.mouse

    def click(self,x:float,y:float,delay:float=0,button:Literal["left", "middle", "right"]='left'):
        stepText = f'步骤：鼠标单击【{x,y}】'
        with allure.step(stepText):
            logging.info(stepText)
            self._mouse.click(x,y,delay=delay,button=button)

    def dblclick(self,x:float,y:float,delay:float=0,button:Literal["left", "middle", "right"]='left'):
        stepText = f'步骤：鼠标双击【{x,y}】'
        with allure.step(stepText):
            logging.info(stepText)
            self._mouse.dblclick(x,y,delay=delay,button=button)

    def move(self,x:float,y:float,steps:int=1):
        stepText = f'步骤：鼠标移动到【{x,y}】'
        with allure.step(stepText):
            logging.info(stepText)
            self._mouse.move(x,y,steps=steps)

    def wheel(self,delta_x:float,delta_y:float):
        stepText = f'步骤：鼠标滚轮操作【{delta_x,delta_y}】'
        with allure.step(stepText):
            logging.info(stepText)
            self._mouse.wheel(delta_x,delta_y)

    
